/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package combomodel.combustivel;

import eloma.classe.carro.Carro;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.ComboBoxModel;

/**
 *
 * @author Icaro
 */
public class ComboBoxVeiculoModel extends AbstractListModel implements ComboBoxModel {

    private List<Carro> listaCarro;
    private Carro selection;

    public ComboBoxVeiculoModel(List<Carro> listaCarro) {
        this.listaCarro = listaCarro;
    }

    @Override
    public int getSize() {
        return listaCarro.size();
    }

    @Override
    public Object getElementAt(int index) {
        return listaCarro.get(index);
    }

    @Override
    public void setSelectedItem(Object anItem) {
        selection = (Carro) anItem;
    }

    @Override
    public Object getSelectedItem() {
        return selection;
    }

}
